package com.java.basis.collection;


import java.util.ArrayList;

/**
 * 在集合中不适用泛型的缺点，可能会出现类型转换异常
 * @author wangning
 * @create 2021-04-21 21:28
 */
public class ListNoGeneric {
	public static void main(String[] args) {
		ArrayList arrayList = new ArrayList();
		arrayList.add("xxx");
		arrayList.add("yyy");
		arrayList.add(11);
		arrayList.add(22);
		for (Object o : arrayList) {
			String string = (String) o;
			System.out.println(string);
		}
	}
}
class ListWithGeneric {
	public static void main(String[] args) {
		ArrayList<String> arrayList = new ArrayList<>();
		arrayList.add("xxx");
		arrayList.add("yyy");
//		arrayList.add(11);
//		arrayList.add(22);

		for (String s : arrayList) {
			System.out.println("s = " + s);
		}



	}
}
